// Page_NDISTUNER_ETH_STATS.cpp : implementation file

//created by KI 22.04

#include "stdafx.h"
#include "NDISTunerMainH.h"
#include "Page_NDISTUNER_ETH_STATS.h"
#include ".\page_ndistuner_eth_stats.h"


// CPage_NDISTUNER_ETH_STATS dialog

IMPLEMENT_DYNAMIC(CPage_NDISTUNER_ETH_STATS, CDialog)
CPage_NDISTUNER_ETH_STATS::CPage_NDISTUNER_ETH_STATS(CWnd* pParent /*=NULL*/)
  : CDialog(CPage_NDISTUNER_ETH_STATS::IDD, pParent)
  , m_HScrollCount(0)
  , m_VScrollCount(0)
  , m_IsScannedClientRect(false)
{
}


CPage_NDISTUNER_ETH_STATS::~CPage_NDISTUNER_ETH_STATS()
{
}


void CPage_NDISTUNER_ETH_STATS::DoDataExchange(CDataExchange* pDX)
{
  CDialog::DoDataExchange(pDX);
  DDX_Control(pDX, IDC_EDIT_RcvErrorAlignment, m_Edit_RcvErrorAlignment);
  DDX_Control(pDX, IDC_STATIC_RcvErrorAlignment, m_Static_RcvErrorAlignment);
  DDX_Control(pDX, IDC_STATIC_XmitOneCollision, m_Static_XmitOneCollision);
  DDX_Control(pDX, IDC_EDIT_XmitOneCollision, m_Edit_XmitOneCollision);
  DDX_Control(pDX, IDC_EDIT_XmitMoreCollisions, m_Edit_XmitMoreCollisions);
  DDX_Control(pDX, IDC_STATIC_XmitMoreCollisions, m_Static_XmitMoreCollisions);
  DDX_Control(pDX, IDC_STATIC_XmitDeferred, m_Static_XmitDeferred);
  DDX_Control(pDX, IDC_EDIT_XmitDeferred, m_Edit_XmitDeferred);
  DDX_Control(pDX, IDC_STATIC_XmitMaxCollisions, m_Static_XmitMaxCollisions);
  DDX_Control(pDX, IDC_EDIT_XmitMaxCollisions, m_Edit_XmitMaxCollisions);
  DDX_Control(pDX, IDC_STATIC_RcvOverrun, m_Static_RcvOverrun);
  DDX_Control(pDX, IDC_EDIT_RcvOverrun, m_Edit_RcvOverrun);
  DDX_Control(pDX, IDC_STATIC_XmitUnderrun, m_Static_XmitUnderrun);
  DDX_Control(pDX, IDC_EDIT_XmitUnderrun, m_Edit_XmitUnderrun);
  DDX_Control(pDX, IDC_STATIC_XmitHeartbeatFailure, m_Static_XmitHeartbeatFailure);
  DDX_Control(pDX, IDC_EDIT_XmitHeartbeatFailure, m_Edit_XmitHeartbeatFailure);
  DDX_Control(pDX, IDC_STATIC_XmitTimesCrsLost, m_Static_XmitTimesCrsLost);
  DDX_Control(pDX, IDC_EDIT_XmitTimesCrsLost, m_Edit_XmitTimesCrsLost);
  DDX_Control(pDX, IDC_STATIC_XmitLateCollisions, m_Static_XmitLateCollisions);
  DDX_Control(pDX, IDC_EDIT_XmitLateCollisions, m_Edit_XmitLateCollisions);
}


BEGIN_MESSAGE_MAP(CPage_NDISTUNER_ETH_STATS, CDialog)
END_MESSAGE_MAP()


void CPage_NDISTUNER_ETH_STATS::mScroll(int h, int v)
{
  m_HScrollCount += h;
  m_VScrollCount += v;
  v = -v;
  h = -h;
  RECT r;
 
  m_Edit_RcvErrorAlignment.GetWindowRect(&r);
  PrepareRect(&r, h, v);
  m_Edit_RcvErrorAlignment.MoveWindow(&r, true);
  m_Static_RcvErrorAlignment.GetWindowRect(&r);
  PrepareRect(&r, h, v);
  m_Static_RcvErrorAlignment.MoveWindow(&r, true);

  m_Edit_XmitOneCollision.GetWindowRect(&r);
  PrepareRect(&r, h, v);
  m_Edit_XmitOneCollision.MoveWindow(&r, true);
  m_Static_XmitOneCollision.GetWindowRect(&r);
  PrepareRect(&r, h, v);
  m_Static_XmitOneCollision.MoveWindow(&r, true);
  
  m_Edit_XmitMoreCollisions.GetWindowRect(&r);
  PrepareRect(&r, h, v);
  m_Edit_XmitMoreCollisions.MoveWindow(&r, true);
  m_Static_XmitMoreCollisions.GetWindowRect(&r);
  PrepareRect(&r, h, v);
  m_Static_XmitMoreCollisions.MoveWindow(&r, true);

  m_Edit_XmitDeferred.GetWindowRect(&r);
  PrepareRect(&r, h, v);
  m_Edit_XmitDeferred.MoveWindow(&r, true);
  m_Static_XmitDeferred.GetWindowRect(&r);
  PrepareRect(&r, h, v);
  m_Static_XmitDeferred.MoveWindow(&r, true);
  
  m_Edit_XmitMaxCollisions.GetWindowRect(&r);
  PrepareRect(&r, h, v);
  m_Edit_XmitMaxCollisions.MoveWindow(&r, true);
  m_Static_XmitMaxCollisions.GetWindowRect(&r);
  PrepareRect(&r, h, v);
  m_Static_XmitMaxCollisions.MoveWindow(&r, true);
  
  m_Edit_RcvOverrun.GetWindowRect(&r);
  PrepareRect(&r, h, v);
  m_Edit_RcvOverrun.MoveWindow(&r, true);
  m_Static_RcvOverrun.GetWindowRect(&r);
  PrepareRect(&r, h, v);
  m_Static_RcvOverrun.MoveWindow(&r, true);
  
  m_Edit_XmitUnderrun.GetWindowRect(&r);
  PrepareRect(&r, h, v);
  m_Edit_XmitUnderrun.MoveWindow(&r, true);
  m_Static_XmitUnderrun.GetWindowRect(&r);
  PrepareRect(&r, h, v);
  m_Static_XmitUnderrun.MoveWindow(&r, true);
  
  m_Edit_XmitHeartbeatFailure.GetWindowRect(&r);
  PrepareRect(&r, h, v);
  m_Edit_XmitHeartbeatFailure.MoveWindow(&r, true);
  m_Static_XmitHeartbeatFailure.GetWindowRect(&r);
  PrepareRect(&r, h, v);
  m_Static_XmitHeartbeatFailure.MoveWindow(&r, true);
  
  m_Edit_XmitTimesCrsLost.GetWindowRect(&r);
  PrepareRect(&r, h, v);
  m_Edit_XmitTimesCrsLost.MoveWindow(&r, true);
  m_Static_XmitTimesCrsLost.GetWindowRect(&r);
  PrepareRect(&r, h, v);
  m_Static_XmitTimesCrsLost.MoveWindow(&r, true);
  
  m_Edit_XmitLateCollisions.GetWindowRect(&r);
  PrepareRect(&r, h, v);
  m_Edit_XmitLateCollisions.MoveWindow(&r, true);
  m_Static_XmitLateCollisions.GetWindowRect(&r);
  PrepareRect(&r, h, v);
  m_Static_XmitLateCollisions.MoveWindow(&r, true);

}


BOOL CPage_NDISTUNER_ETH_STATS::OnInitDialog()
{

  CDialog::OnInitDialog();

  m_Edit_RcvErrorAlignment.SetWindowText("not set");
  m_Edit_RcvErrorAlignment.EnableWindow(false);

  m_Edit_XmitOneCollision.SetWindowText("not set");
  m_Edit_XmitOneCollision.EnableWindow(false);
 
  m_Edit_XmitMoreCollisions.SetWindowText("not set");
  m_Edit_XmitMoreCollisions.EnableWindow(false);
  
  m_Edit_XmitDeferred.SetWindowText("not set");
  m_Edit_XmitDeferred.EnableWindow(false);
 
  m_Edit_XmitMaxCollisions.SetWindowText("not set");
  m_Edit_XmitMaxCollisions.EnableWindow(false);
  
  m_Edit_RcvOverrun.SetWindowText("not set");
  m_Edit_RcvOverrun.EnableWindow(false);
  
  m_Edit_XmitUnderrun.SetWindowText("not set");
  m_Edit_XmitUnderrun.EnableWindow(false);
  
  m_Edit_XmitHeartbeatFailure.SetWindowText("not set");
  m_Edit_XmitHeartbeatFailure.EnableWindow(false);
  
  m_Edit_XmitTimesCrsLost.SetWindowText("not set");
  m_Edit_XmitTimesCrsLost.EnableWindow(false);
  
  m_Edit_XmitLateCollisions.SetWindowText("not set");
  m_Edit_XmitLateCollisions.EnableWindow(false);

  return TRUE; 
}

// functions prepares rectangle of control to move this control
void CPage_NDISTUNER_ETH_STATS::PrepareRect(LPRECT pR, int h, int v)
{
  RECT m_R;
  GetWindowRect(&m_R);

  pR->bottom += v - m_R.top - 2;
  pR->top += v - m_R.top - 2;
  pR->left += h - m_R.left - 2;
  pR->right += h - m_R.left - 2;
}

// function returns original client rect
void CPage_NDISTUNER_ETH_STATS::GetClientRect(LPRECT lpRect)
{
  if(m_IsScannedClientRect)
  {
    *lpRect = m_OriginalClientRect;
    return;
  }
  CDialog::GetClientRect(lpRect);
  m_OriginalClientRect = *lpRect;
  m_IsScannedClientRect = true;
}



